package cn.foo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Frank
 * @date 07-06
 */
@Controller//控制器
public class HelloController {
    //Logger logger = LogManager.getLogger();
    @RequestMapping("/hello")//localhost:8080/hello
    public String hello(){
        System.out.println("Spring MVC");
        //logger.info("Spring MVC");
        return "hello";
    }
    //ali fastjson  gson jackson
    @RequestMapping("/index")//localhost:8080/hello
    @ResponseBody//方法返回JSON字符串
    public Map index(){
        System.out.println("Spring MVC");
        //logger.info("Spring MVC");
        Map<String,Object> map = new HashMap<>();
        map.put("userName","admin");
        String admin = "\"username\":\"admin\"";
        return map;
    }
}
